package net.lijingye.education.request.validator;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.Arrays;

/**
 * Created by LijingYe on 2016/3/26.
 */
public class GenderValidator implements ConstraintValidator<Gender, String> {
    private final String[] ALL_GENDER = {"-1", "0", "1"};

    public void initialize(Gender gender) {
    }

    public boolean isValid(String value, ConstraintValidatorContext context) {
        if (value==null||Arrays.asList(ALL_GENDER).contains(value))
            return true;
        return false;
    }
}
